package de.slothsoft.wasbinich.core.database;

public abstract class Database {

    private static Database instance;

    public static void initInstance(Database newInstance) {
	// if (WasBinIch.version != null)
	// throw new IllegalArgumentException();
	instance = newInstance;
    }

    public static Database getInstance() {
	return instance;
    }

    private PictureBean pictureBean;
    private ApplicationBean applicationBean;
    private ManagerBean managerBean;
    // private PhotographerBean photographerBean;
    private LoginBean loginBean;

    public void setPictureBean(PictureBean pictureBean) {
	this.pictureBean = pictureBean;
    }

    public synchronized PictureBean getPictureBean() {
	if (this.pictureBean == null) {
	    this.pictureBean = createPictureBean();
	}
	return this.pictureBean;
    }

    protected abstract PictureBean createPictureBean();

    public void setApplicationBean(ApplicationBean applicationBean) {
	this.applicationBean = applicationBean;
    }

    public synchronized ApplicationBean getApplicationBean() {
	if (this.applicationBean == null) {
	    this.applicationBean = createApplicationBean();
	}
	return this.applicationBean;
    }

    protected abstract ApplicationBean createApplicationBean();

    public void setManagerBean(ManagerBean managerBean) {
	this.managerBean = managerBean;
    }

    public synchronized ManagerBean getManagerBean() {
	if (this.managerBean == null) {
	    this.managerBean = createManagerBean();
	}
	return this.managerBean;
    }

    protected abstract ManagerBean createManagerBean();

    // public void setPhotographerBean(PhotographerBean
    // photographerPhotographer) {
    // this.photographerBean = photographerPhotographer;
    // }
    //
    // public synchronized PhotographerBean getPhotographerBean() {
    // if (this.photographerBean == null) {
    // this.photographerBean = createPhotographerBean();
    // }
    // return this.photographerBean;
    // }
    //
    // protected abstract PhotographerBean createPhotographerBean();

    public void setLoginBean(LoginBean loginBean) {
	this.loginBean = loginBean;
    }

    public synchronized LoginBean getLoginBean() {
	if (this.loginBean == null) {
	    this.loginBean = createLoginBean();
	}
	return this.loginBean;
    }

    protected abstract LoginBean createLoginBean();
}
